using UnityEngine;

namespace Crosstales.Common.Util
{
    // [Assembly-CSharp-firstpass.dll].Crosstales.Common.Util.PlatformController
    public class PlatformController : MonoBehaviour
    {
        
        #region Crosstales.Common.Util.PlatformController.<>c
        // [Assembly-CSharp-firstpass.dll].Crosstales.Common.Util.PlatformController.<>c
        [Serializable]
        private sealed class __c
        {
            // Fields
            public static readonly Crosstales.Common.Util.PlatformController.<>c __9;
            public static System.Func<UnityEngine.GameObject, bool> __9__8_0;
            public static System.Func<UnityEngine.MonoBehaviour, bool> __9__9_0;
            
            // Methods
            private static __c()
            {
                object val_1 = 536899605;
                val_1 = new System.Object();
                mem2[0] = val_1;
                throw new NullReferenceException();
            }
            public __c()
            {
            
            }
            internal bool <activateGameObjects>b__8_0(UnityEngine.GameObject go)
            {
                if(mem[536890429] != 0)
                {
                        return UnityEngine.Object.op_Inequality(x:  go, y:  0);
                }
                
                return UnityEngine.Object.op_Inequality(x:  go, y:  0);
            }
            internal bool <activateScripts>b__9_0(UnityEngine.MonoBehaviour script)
            {
                if(mem[536890429] != 0)
                {
                        return UnityEngine.Object.op_Inequality(x:  script, y:  0);
                }
                
                return UnityEngine.Object.op_Inequality(x:  script, y:  0);
            }
        
        }
        
        #endregion
        
        // Fields
        public System.Collections.Generic.List<Crosstales.Common.Model.Enum.Platform> Platforms;
        public bool Active;
        public UnityEngine.GameObject[] Objects;
        public UnityEngine.MonoBehaviour[] Scripts;
        protected Crosstales.Common.Model.Enum.Platform currentPlatform;
        
        // Methods
        protected virtual void Awake()
        {
            if(this.enabled == false)
            {
                    return;
            }
            
            this.selectPlatform();
        }
        private void Start()
        {
        
        }
        protected void selectPlatform()
        {
            Crosstales.Common.Model.Enum.Platform val_1 = Crosstales.Common.Util.BaseHelper.CurrentPlatform;
            this.currentPlatform = 4;
            this.activateGameObjects();
            this.activateScripts();
        }
        protected void activateGameObjects()
        {
            var val_11;
            Unknown val_12;
            Crosstales.Common.Model.Enum.Platform val_13;
            var val_14;
            System.Func<Unknown, System.Boolean> val_15;
            object val_16;
            var val_17;
            var val_18;
            var val_19;
            var val_20;
            var val_21;
            val_12 = this;
            if(this.Objects == null)
            {
                    return;
            }
            
            if(this.Objects.Length == 0)
            {
                    return;
            }
            
            if(this.Platforms == null)
            {
                    throw new NullReferenceException();
            }
            
            val_13 = this.currentPlatform;
            val_14 = 536899605;
            val_12 = this.Objects;
            val_11 = this.Platforms.Contains(item:  val_13);
            if(mem[536899829] == 0)
            {
                    val_14 = 536899605;
            }
            
            val_15 = mem[mem[536899789] + 8];
            val_15 = mem[536899789] + 8;
            if(val_15 == 0)
            {
                    if(mem[536899829] == 0)
            {
                    val_14 = 536899605;
            }
            
                System.Func<System.Object, System.Boolean> val_2 = 536903137;
                val_16 = mem[mem[536899789]];
                val_16 = mem[536899789];
                if(val_2 == 0)
            {
                    throw new NullReferenceException();
            }
            
                val_15 = val_2;
                val_2 = new System.Func<System.Object, System.Boolean>(object:  val_16, method:  1610683421);
                mem2[0] = val_15;
            }
            
            val_13 = val_15;
            System.Collections.Generic.IEnumerable<Unknown> val_3 = System.Linq.Enumerable.Where<System.Object>(source:  val_12, predicate:  val_13);
            if(val_3 == null)
            {
                    throw new NullReferenceException();
            }
            
            val_17 = val_3;
            val_16 = 27348040;
            val_12 = val_3;
            val_11 = 27348184;
            label_24:
            val_18 = val_12;
            if((val_12 & 1) == 0)
            {
                goto label_18;
            }
            
            val_19 = val_12;
            if(val_12 == null)
            {
                    throw new NullReferenceException();
            }
            
            val_12.SetActive(value:  (this.Active != ((~val_11) & 1)) ? 1 : 0);
            goto label_24;
            label_18:
            val_11 = 0;
            label_36:
            if(val_12 != null)
            {
                    val_20 = val_12;
            }
            
            if(val_11 == 0)
            {
                    return;
            }
            
            if(536903483 != 1)
            {
                goto label_35;
            }
            
            goto label_36;
            label_35:
            if(val_12 == null)
            {
                goto label_44;
            }
            
            label_43:
            val_21 = val_12;
            label_44:
            if(val_12 != null)
            {
                goto label_43;
            }
            
            goto label_44;
        }
        protected void activateScripts()
        {
            var val_11;
            Unknown val_12;
            Crosstales.Common.Model.Enum.Platform val_13;
            var val_14;
            System.Func<Unknown, System.Boolean> val_15;
            object val_16;
            var val_17;
            var val_18;
            var val_19;
            var val_20;
            var val_21;
            val_12 = this;
            if(this.Scripts == null)
            {
                    return;
            }
            
            if(this.Scripts.Length == 0)
            {
                    return;
            }
            
            if(this.Platforms == null)
            {
                    throw new NullReferenceException();
            }
            
            val_13 = this.currentPlatform;
            val_14 = 536899605;
            val_12 = this.Scripts;
            val_11 = this.Platforms.Contains(item:  val_13);
            if(mem[536899829] == 0)
            {
                    val_14 = 536899605;
            }
            
            val_15 = mem[mem[536899789] + 16];
            val_15 = mem[536899789] + 16;
            if(val_15 == 0)
            {
                    if(mem[536899829] == 0)
            {
                    val_14 = 536899605;
            }
            
                System.Func<System.Object, System.Boolean> val_2 = 536903169;
                val_16 = mem[mem[536899789]];
                val_16 = mem[536899789];
                if(val_2 == 0)
            {
                    throw new NullReferenceException();
            }
            
                val_15 = val_2;
                val_2 = new System.Func<System.Object, System.Boolean>(object:  val_16, method:  1610683423);
                mem2[0] = val_15;
            }
            
            val_13 = val_15;
            System.Collections.Generic.IEnumerable<Unknown> val_3 = System.Linq.Enumerable.Where<System.Object>(source:  val_12, predicate:  val_13);
            if(val_3 == null)
            {
                    throw new NullReferenceException();
            }
            
            val_17 = val_3;
            val_16 = 27348040;
            val_12 = val_3;
            val_11 = 27348184;
            label_24:
            val_18 = val_12;
            if((val_12 & 1) == 0)
            {
                goto label_18;
            }
            
            val_19 = val_12;
            if(val_12 == null)
            {
                    throw new NullReferenceException();
            }
            
            val_12.enabled = (this.Active != ((~val_11) & 1)) ? 1 : 0;
            goto label_24;
            label_18:
            val_11 = 0;
            label_36:
            if(val_12 != null)
            {
                    val_20 = val_12;
            }
            
            if(val_11 == 0)
            {
                    return;
            }
            
            if(536903493 != 1)
            {
                goto label_35;
            }
            
            goto label_36;
            label_35:
            if(val_12 == null)
            {
                goto label_44;
            }
            
            label_43:
            val_21 = val_12;
            label_44:
            if(val_12 != null)
            {
                goto label_43;
            }
            
            goto label_44;
        }
        public PlatformController()
        {
            this.Active = true;
        }
    
    }

}
